<?php

class AjaxcallModule extends fvModule {

    function __construct () {
        $moduleName = strtolower(substr(__CLASS__, 0, -6));

        parent::__construct(fvSite::$fvConfig->get("modules.{$moduleName}.smarty.template"), 
                            fvSite::$fvConfig->get("modules.{$moduleName}.smarty.compile"), 
                            fvSite::$Layoult);
    }

	function showShowfilters() {
        if (strlen($filtersList = fvRequest::getInstance()->getRequestParameter("filterList")) > 0) {
            $filtersList = str_replace('"','',$filtersList);
            $filtersList = str_replace('\\','',$filtersList);
        	$filtersList = explode(',', $filtersList);
        } else {
            $filtersList = array();
        }
        
        $Filters = FilterManager::getInstance()->getAll(null, 'title');
		$this->__assign(array(
            'selectedFilters' => $filtersList,
            'Filters'    => $Filters,
        ));
        
        return $this->__display('ajax_filters.tpl');
    }
    
	function showShowgroups() {
		
        if (strlen($groupsList = fvRequest::getInstance()->getRequestParameter("groupsList")) > 0) {
            $groupsList = str_replace('"','',$groupsList);
            $groupsList = str_replace('\\','',$groupsList);
        	$groupsList = explode(',', $groupsList);
        } else {
            $groupsList = array(1);
        }
        $Groups = SubscribersGroupManager::getInstance()->getAll(null, 'group_name');
		$this->__assign(array(
            'selectedGroups' => $groupsList,
            'Groups'    => $Groups,
        ));
        
        return $this->__display('ajax_groups.tpl');
    }
    
	function showShowtemplates() {
		
        if (strlen($templatesList = fvRequest::getInstance()->getRequestParameter("templatesList")) > 0) {
            $templatesList = str_replace('"','',$templatesList);
            $templatesList = str_replace('\\','',$templatesList);
        	$templatesList = explode(',', $templatesList);
        } else {
            $templatesList = array(1);
        }
        $Templates = SubscribeTemplatesManager::getInstance()->getAll(null, 'title');
		$this->__assign(array(
            'selectedTemplates' => $templatesList,
            'Templates'    => $Templates,
        ));
        
        return $this->__display('ajax_templates.tpl');
    }
    
	function showUpdatefilters() {
        $request = fvRequest::getInstance();
        if (SectionsManager::getInstance()->getByPk($request->getEscapedParameter('category_id'))->filters){
	        $Filters = FilterManager::getInstance()->getAll("id in (".SectionsManager::getInstance()->getByPk($request->getEscapedParameter('category_id'))->filters.")");
        }
        $this->__assign(array(
        	'Filters' => $Filters,
        ));
        return $this->__display('ajax_filters_update.tpl');
    }
}

?>
